﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MediatR;
using RBAC.Write.Api.Application.Command.ERP.WarehouseManagement;
using RBAC.ErrorCode;

namespace RBAC.Write.Api.Controllers.ERP
{
    /// <summary>
    /// 仓库管理
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class WarehouseManagementController : ControllerBase
    {
        private readonly IMediator _mediator;

        public WarehouseManagementController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 新增仓库
        /// </summary>
        /// <param name="request">仓库信息</param>
        /// <returns>新增结果</returns>
        [HttpPost("AddWarehouseList")]
        public async Task<APIResult<int>> AddWarehouseList([FromBody] AddWarehouseListCommands request)
        {
            return await _mediator.Send(request);
        }

        /// <summary>
        /// 修改仓库
        /// </summary>
        /// <param name="request">仓库信息</param>
        /// <returns>修改结果</returns>
        [HttpPut("UpdateWarehouseList")]
        public async Task<APIResult<int>> UpdateWarehouseList([FromBody] UpdateWarehouseListCommands request)
        {
            return await _mediator.Send(request);
        }

        /// <summary>
        /// 删除仓库
        /// </summary>
        /// <param name="request">删除参数</param>
        /// <returns>删除结果</returns>
        [HttpDelete("DeleteWarehouseList")]
        public async Task<APIResult<int>> DeleteWarehouseList([FromBody] DeleteWarehouseListCommands request)
        {
            return await _mediator.Send(request);
        }
    }
}
